package org.example.entity;


import org.example.utils.TableStrUtil;

import java.io.File;

/**
 * dao模板对应的信息继承至TemplateInfoEntity
 */
public class TemplateInfoDaoEntity extends TemplateInfoEntity {

    /**
     * 构造器
     *
     * @param packagePath           包名
     * @param filePath              文件路径
     * @param templateName          模板名称
     * @param implementsPackagePath 实现接口的包
     * @param className             类名
     * @param varName               变量名
     */
    public TemplateInfoDaoEntity(String packagePath, String filePath, String templateName, String implementsPackagePath, String className, String varName) {
        super(packagePath, filePath, templateName, implementsPackagePath, className, varName);
    }

    /**
     * 构造器
     *
     * @param project   项目信息
     * @param tableName 表名
     */
    public TemplateInfoDaoEntity(ProjectInfoEntity project, String tableName) {
        super(project);
        //模板名称
        super.templateName = "DAOTemplate.ftl";
        //类名
        super.className = TableStrUtil.getClassName(tableName).append("Mapper").toString();
        //变量名
        super.varName = TableStrUtil.getVarName(tableName).append("Mapper").toString();
        //包名
        String packagePath = project.getPackagePrefix() + ".mapper";
        super.packagePath = packagePath;
        //文件路径
        String filePath = project.getFilePrefix() + File.separator + project.getJavaBasePath() + TableStrUtil.packageToFile(packagePath);
        super.filePath = filePath;
        //实现接口
        super.implementsPackagePath = "com.zwba1.common.utils.mybatis.dao.CrudMapper";
    }


    @Override
    public String toString() {
        return super.toString();
    }
}
